#include<bits/stdc++.h>
using namespace std;
int n,m,b,u,v;
bitset<55000> bs[55000],tmp;
bool inque[55000];
queue<int> qu;
long long ans;
int main() {
    freopen("grid.in","r",stdin);
    freopen("grid.out","w",stdout);
    scanf("%d%d%d",&n,&m,&b);
    for (int i=1;i<=b;i++) {
        scanf("%d%d",&u,&v);
        bs[u+1][v]=1;
    }
    for (int i=2;i<=n+1;i++) {
        bs[i]|=(bs[i]<<1)&(bs[i]>>1);
        qu.push(i);
        inque[i]=true;
    }
    while (qu.size()) {
        int x=qu.front();
        qu.pop();
        inque[x]=false;
        bool f=false,g=false;
        do {
            tmp=bs[x-1];
            bs[x-1]|=bs[x]&bs[x-2];
            bs[x-1]|=(bs[x]|bs[x-2])&((bs[x-1]<<1)|(bs[x-1]>>1));
            bs[x-1]|=(bs[x-1]<<1)&(bs[x-1]>>1);
            f=(bs[x-1]!=tmp);
            g|=f;
        } while (f);
        if (g) {
            if (!inque[x-1]) {
                qu.push(x-1);
                inque[x-1]=true;
            }
        }
        f=false,g=false;
        do {
            tmp=bs[x+1];
            bs[x+1]|=bs[x]&bs[x+2];
            bs[x+1]|=(bs[x]|bs[x+2])&((bs[x+1]<<1)|(bs[x+1]>>1));
            bs[x+1]|=(bs[x+1]<<1)&(bs[x+1]>>1);
            f=(bs[x+1]!=tmp);
            g|=f;
        } while (f);
        if (g) {
            if (!inque[x+1]) {
                qu.push(x+1);
                inque[x+1]=true;
            }
        }
    }
    for (int i=2;i<=n+1;i++) ans+=bs[i].count();
    cout<<ans<<endl;
    return 0;
}
